package com.axing.springbootinit.service.impl.inner;

import com.alibaba.nacos.common.utils.StringUtils;
import com.axing.model.entity.InterfaceInfo;
import com.axing.service.InnerInterfaceInfoService;
import com.axing.springbootinit.common.ErrorCode;
import com.axing.springbootinit.exception.BusinessException;
import com.axing.springbootinit.mapper.InterfaceInfoMapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.dubbo.config.annotation.DubboService;

import javax.annotation.Resource;
@DubboService
public class InnerInterfaceInfoServiceImpl implements InnerInterfaceInfoService {
    @Resource
    private InterfaceInfoMapper interfaceInfoMapper;

    @Override
    public InterfaceInfo getInterfaceInfo(String url, String method) {
        if(StringUtils.isAnyBlank(url,method)){
            throw  new BusinessException(ErrorCode.PARAMS_ERROR);
        }
        
        QueryWrapper<InterfaceInfo> interfaceInfoQueryWrapper = new QueryWrapper<>();
        interfaceInfoQueryWrapper.eq("url", url);
        interfaceInfoQueryWrapper.eq("method", method);
        InterfaceInfo interfaceInfo = interfaceInfoMapper.selectOne(interfaceInfoQueryWrapper);
        return interfaceInfo;
    }
}
